package com.hksj.Intelligentmanagement.service;

import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hksj.Intelligentmanagement.auth.entity.LoginUser;
import com.hksj.Intelligentmanagement.common.Constants;
import com.hksj.Intelligentmanagement.dto.*;
import com.hksj.Intelligentmanagement.entity.AurgicalAssistantRelationEntity;
import com.hksj.Intelligentmanagement.entity.SurgicalEntity;
import com.hksj.Intelligentmanagement.entity.SurgicalRoomEntity;
import com.hksj.Intelligentmanagement.entity.WnReadHandNumbness;
import com.hksj.Intelligentmanagement.enums.ShiftsEnum;
import com.hksj.Intelligentmanagement.mapper.SurgicalMapper;
import com.hksj.Intelligentmanagement.utils.ExcelToImageUtil;
import com.hksj.Intelligentmanagement.utils.ExportExcelUtil;
import com.hksj.Intelligentmanagement.vo.*;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author @chenxingqing
 * @Version 1.0
 */
@Service
public class SurgicalService extends ServiceImpl<SurgicalMapper, SurgicalEntity> {
    @Autowired
    private SurgicalAssistantRelationService assistantRelationService;

    @Autowired
    private SurgicalRoomService surgicalRoomService;

    @Autowired
    private ShiftsService shiftsService;

    @Autowired
    private NurseService nurseService;

    @Autowired
    private UserRegionService userRegionService;

    public static final Integer SCHEDULED_STATUS = 1;
    public static final Integer SCHEDULING_STATUS = 2;
    public static final Integer UNSCHEDULED_STATUS = 0;

    /**
     * 查询手术信息
     *
     * @param time
     * @param masterDoctorName
     * @param patientName
     * @param schedulingStatus
     * @param regionId
     * @return
     */
    public List<SurgicalVo> listAllSurgical(String time, String masterDoctorName, String patientName, Integer schedulingStatus, String regionId) {
        //查所有手术信息
        List<SurgicalVo> list = baseMapper.listAllSurgical(time,masterDoctorName,patientName,schedulingStatus,regionId,null);
        return list;
    }

    /**
     * 查询已排班的手术信息
     *
     * @param time
     * @param nurseName
     * @param regionIds
     * @param schedulingStatus
     * @return
     */
    public List<SurgicalVo> listScheduledSurgical(String time, String nurseName, List<String> regionIds, Integer schedulingStatus) {
        List<SurgicalVo> surgicalVos = baseMapper.listScheduledSurgical(time, nurseName, regionIds,schedulingStatus);
        surgicalVos.stream().forEach(surgicalVo -> {
            if (surgicalVo.getSex() == 1){
                surgicalVo.setSexStr("男");
            }else{
                surgicalVo.setSexStr("女");
            }
        });
        return surgicalVos;
    }

    /**
     * 提交护士排班
     * @param roomAndAssistantDTO
     */
    @Transactional
    public void schedulingSurgical(SurgicalRoomAndAssistantDTO roomAndAssistantDTO,Boolean isCheck) {

        //检查区域权限
        if (isCheck){
            checkRegion(roomAndAssistantDTO.getRegionId());
        }

        //如果没有手术信息 不走逻辑
        if (ObjectUtils.isEmpty(roomAndAssistantDTO.getSurgicalId())){
            return;
        }

        if (!ObjectUtils.isEmpty(roomAndAssistantDTO.getRelationId())){
            SurgicalRoomEntity dbData = surgicalRoomService.getById(roomAndAssistantDTO.getRelationId());
            if (!Objects.equals(dbData.getSurgicalId(),roomAndAssistantDTO.getSurgicalId())){
                SurgicalEntity surgical = getById(dbData.getSurgicalId());
                if (surgical.getSchedulingStatus() == 1){
                    return;
                }else {
                    switchSchedulingStatus(dbData.getSurgicalId(), UNSCHEDULED_STATUS);

                    //删除护士关联关系
                    LambdaQueryWrapper<AurgicalAssistantRelationEntity> assistantQueryWrapper = new QueryWrapper<AurgicalAssistantRelationEntity>().lambda().
                            eq(AurgicalAssistantRelationEntity::getSurgicalInfoId, dbData.getSurgicalId())
                            .in(AurgicalAssistantRelationEntity::getType,Arrays.asList(3,4,5));
                    assistantRelationService.remove(assistantQueryWrapper);
                }
            }
        }

        Date now = new Date();

        //删除护士关联关系
        LambdaQueryWrapper<AurgicalAssistantRelationEntity> assistantQueryWrapper = new QueryWrapper<AurgicalAssistantRelationEntity>().lambda().
                eq(AurgicalAssistantRelationEntity::getSurgicalInfoId, roomAndAssistantDTO.getSurgicalId())
                .in(AurgicalAssistantRelationEntity::getType,Arrays.asList(3,4,5));
        assistantRelationService.remove(assistantQueryWrapper);

        //保存护士关联关系
        saveSurgicalAssistant(roomAndAssistantDTO);

        //保存手术间关联关系
        SurgicalRoomEntity surgicalRoomEntity = new SurgicalRoomEntity();
        BeanUtils.copyProperties(roomAndAssistantDTO,surgicalRoomEntity);
        //根据relationId判断是新增还是修改
        if (StringUtils.hasText(roomAndAssistantDTO.getRelationId())){
            //修改
            surgicalRoomEntity.setId(roomAndAssistantDTO.getRelationId());
            surgicalRoomService.updateById(surgicalRoomEntity);
        }else{
            //新增
            surgicalRoomEntity.setCreateTime(now);
            surgicalRoomEntity.setUpdateTime(now);
            //设置手术排班时间
            surgicalRoomEntity.setOperateTime(DateUtil.parse(roomAndAssistantDTO.getOperateTime(),"yyyy-MM-dd"));
            //获取手术间当天的手术台数,设置手术序号
            Integer num = surgicalRoomService.getSurgicalNumByRoomId(roomAndAssistantDTO.getRoomId(),roomAndAssistantDTO.getOperateTime());
            surgicalRoomEntity.setSortNo(ObjectUtils.isEmpty(num) ? 0 : num + 1);
            surgicalRoomService.save(surgicalRoomEntity);
        }
        //更新排班状态
        this.switchSchedulingStatus(roomAndAssistantDTO.getSurgicalId(),roomAndAssistantDTO.getStatus() == 1 ? SCHEDULED_STATUS : SCHEDULING_STATUS);
    }

    /**
     * 保存手术相关人员关联关系
     * @param roomAndAssistantDTO
     */
    private void saveSurgicalAssistant(SurgicalRoomAndAssistantDTO roomAndAssistantDTO) {
        Date now = new Date();
        List<AurgicalAssistantRelationEntity> assistantList = new ArrayList<>();
        AurgicalAssistantRelationEntity tAssistant = null;
        if (!ObjectUtils.isEmpty(roomAndAssistantDTO.getNurseList())){
            for (NurseSimpleDTO nurseSimpleDTO : roomAndAssistantDTO.getNurseList()) {
                tAssistant = new AurgicalAssistantRelationEntity();
                tAssistant.setSurgicalInfoId(roomAndAssistantDTO.getSurgicalId());
                tAssistant.setAnesthesiaInfoId(nurseSimpleDTO.getId());
                tAssistant.setType(nurseSimpleDTO.getType());
                tAssistant.setCreateTime(now);
                tAssistant.setUpdateTime(now);
                assistantList.add(tAssistant);
            }
            assistantRelationService.saveBatch(assistantList);
        }
    }

    /**
     * 取消护士排班
     * @param surgicalId
     */
    @Transactional
    public void cancelSchedulingSurgical(String surgicalId) {
        SurgicalRoomEntity surgicalRoom = surgicalRoomService.lambdaQuery()
                .eq(SurgicalRoomEntity::getSurgicalId, surgicalId)
                .last("limit 1")
                .one();
        checkRegion(surgicalRoom.getRegionId());

        //删除护士关联关系
        LambdaQueryWrapper<AurgicalAssistantRelationEntity> assistantQueryWrapper = new QueryWrapper<AurgicalAssistantRelationEntity>().lambda().
                eq(AurgicalAssistantRelationEntity::getSurgicalInfoId, surgicalId)
                .in(AurgicalAssistantRelationEntity::getType,Arrays.asList(3,4,5));
        assistantRelationService.remove(assistantQueryWrapper);

        //删除手术间关联关系
        LambdaQueryWrapper<SurgicalRoomEntity> roomQueryWrapper = new QueryWrapper<SurgicalRoomEntity>().lambda().
                eq(SurgicalRoomEntity::getSurgicalId, surgicalId);
        surgicalRoomService.remove(roomQueryWrapper);

        //修改手术排班状态
        this.switchSchedulingStatus(surgicalId,UNSCHEDULED_STATUS);
    }

    /**
     * 麻醉人员排班
     * @param roomAndAssistant
     */
    @Transactional
    public void schedulingSurgicalForAnesthesia(SurgicalRoomAndAssistantDTO roomAndAssistant,Boolean isCheck) {
        if (isCheck){
            checkRegion(roomAndAssistant.getRegionId());
        }
        //删除之前排的
        cancelSchedulingSurgicalForAnesthesia(roomAndAssistant.getSurgicalId());
        //重新排班
        saveSurgicalAssistant(roomAndAssistant);
    }

    @Transactional
    public void batchSchedulingSurgicalForAnesthesia(List<SurgicalRoomAndAssistantDTO> roomAndAssistants){
        if (!ObjectUtils.isEmpty(roomAndAssistants)){
            checkRegion(roomAndAssistants.get(0).getRegionId());
            for (SurgicalRoomAndAssistantDTO roomAndAssistant : roomAndAssistants) {
                schedulingSurgicalForAnesthesia(roomAndAssistant,false);
            }
        }
    }

    /**
     * 取消麻醉人员排班
     * @param surgicalId
     */
    public void cancelSchedulingSurgicalForAnesthesia(String surgicalId) {

        SurgicalRoomEntity surgicalRoom = surgicalRoomService.lambdaQuery()
                .eq(SurgicalRoomEntity::getSurgicalId, surgicalId)
                .last("limit 1")
                .one();
        checkRegion(surgicalRoom.getRegionId());

        //删除麻醉关联关系
        LambdaQueryWrapper<AurgicalAssistantRelationEntity> assistantQueryWrapper = new QueryWrapper<AurgicalAssistantRelationEntity>().lambda().
                eq(AurgicalAssistantRelationEntity::getSurgicalInfoId, surgicalId)
                .in(AurgicalAssistantRelationEntity::getType,Arrays.asList(0,1,2,6));
        assistantRelationService.remove(assistantQueryWrapper);
    }

    /**
     * 导出已排班信息
     * @param time
     * @param regionIds
     * @param response
     */
    public void exportSchedulingSurgical(String time, List<String> regionIds, HttpServletResponse response) {
        //获取数据
        List<SurgicalVo> surgicalVos = listScheduledSurgical(time, null, regionIds,1);
        //格式化执刀时间
        if (!ObjectUtils.isEmpty(surgicalVos)){
            SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
            surgicalVos.stream().forEach(surgicalVo -> {
                surgicalVo.setOperateTimeShort(dateFormat.format(surgicalVo.getOperateTime()));
                int hours = surgicalVo.getOperateTime().getHours();
                if (hours >= 8 && hours <= 14){
                    surgicalVo.setNote(Constants.GENERAL_TREATMENT);
                }else{
                    surgicalVo.setNote(Constants.EMERGENCY_TREATMENT);
                }
            });
        }
        //设置表头
        Map<String, String> headerMap = new LinkedHashMap<>();
        headerMap.put("roomName","手术间");
        headerMap.put("operateTimeShort","执刀时间");
        headerMap.put("departmentName","科室");
        headerMap.put("bedCode","床号");
        headerMap.put("patientName","姓名");
        headerMap.put("sexStr","性别");
        headerMap.put("age","年龄");
        headerMap.put("inpatNo","住院号");
        headerMap.put("diagnosis","诊断");
        headerMap.put("surgicalName","手术名称");
        headerMap.put("masterDoctorName","主刀");
        headerMap.put("assistantFirstName","一助");
        headerMap.put("assistantSecondName","二助");
        headerMap.put("assistantThirdName","三助");
        headerMap.put("visitor","参观人员");
        headerMap.put("anaesthesiaType","麻醉方式");
        headerMap.put("anaesthesiaDoctor","麻醉医生");
        headerMap.put("anesthesiaAssistant","手麻助手");
        headerMap.put("anesthesiaInstructor","麻醉指导");
        headerMap.put("washNurse","洗手护士");
        headerMap.put("tourNurse","巡回护士");
        headerMap.put("part","部位");
        headerMap.put("medicalInsuranceType","医保类型");
        headerMap.put("position","体位");
        headerMap.put("note","备注");

        //模板路径
        String templatePath = "classpath:surgical-template.xlsx";
        //文件名称
        String fileName = new StringBuffer()
                .append("手术信息")
                .append(ObjectUtils.isEmpty(time) ? "" : time)
                .append(".xlsx").toString();
        //跳过行数
        Integer skipRows = 12;
        //导出文件
        ExportExcelUtil.export(templatePath,skipRows,fileName,surgicalVos,headerMap,response,writer -> {
            //添加备注字段样式
            formatNoteStyle(writer,surgicalVos.size(),skipRows);
            //表格右上角部分
            generalSchedulingTopRight(writer,time);
            //表格左上角部分
            generalSchedulingTopLeft(writer,time);
        });
    }

    /**
     * 格式化备注字段单元格样式
     */
    private void formatNoteStyle(ExcelWriter writer,Integer recordNum,Integer skipRows){
        Cell curentCell = null;
        for (int i = 0; i < recordNum; i++) {
            curentCell = writer.getCell(24,skipRows + i);
            if (Constants.EMERGENCY_TREATMENT.equals(curentCell.getStringCellValue())){
                //创建单元格样式
                CellStyle cellStyle = writer.createCellStyle(24, skipRows + i);
                cellStyle.setAlignment(HorizontalAlignment.CENTER);
                cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
                BorderStyle borderStyle = BorderStyle.THIN;
                cellStyle.setBorderTop(borderStyle);
                cellStyle.setBorderBottom(borderStyle);
                cellStyle.setBorderLeft(borderStyle);
                cellStyle.setBorderRight(borderStyle);
                //创建字体
                Font font = writer.createFont();
                font.setColor(Font.COLOR_RED);
                //设置样式
                cellStyle.setFont(font);
                curentCell.setCellStyle(cellStyle);
            }
        }
    }

    /**
     * 表格右上角信息导出
     */
    private void generalSchedulingTopRight(ExcelWriter writer, String scheduleTime){
        //右上表
        Map<String, String> dataMap = getDataMap(scheduleTime);
        //拆分管理班
        String manage = dataMap.get(ShiftsEnum.manage.value());
        if (!ObjectUtils.isEmpty(manage)){
            String[] names = manage.split(",");
            String manage1 = names[0];
            dataMap.put(ShiftsEnum.manage1.value(),manage1);
            String manage2 = manage.replace(manage1,"");
            dataMap.put(ShiftsEnum.manage2.value(),manage2);
        }

        //排班右上
        Integer targetWidth = 576;
        Integer targetHeight = 247;
        Double scale = 0.64D;
        Integer embedSheetIndex = 2;
        Integer embedImageIndex = 3;
        List<String> propertyKeys = Arrays.stream(ShiftsEnum.values()).map(shiftsEnum -> shiftsEnum.value()).collect(Collectors.toList());
        //刷新关联对象内容
        ExcelToImageUtil.refreshEmbedObj(writer,dataMap,embedSheetIndex,embedImageIndex,targetWidth,targetHeight,scale,propertyKeys,true,null);
    }

    private void generalSchedulingTopLeft(ExcelWriter writer, String scheduleTime){
        Map<String, String> dataMap = getDataMap(scheduleTime);
        List<NurseSimpleVo> nurseSimpleVos = nurseService.listUnscheduledNurse(scheduleTime, Constants.TYPE_NURSE);
        List<String> names = nurseSimpleVos.stream().map(nurse -> nurse.getName()).collect(Collectors.toList());
        dataMap.put(ShiftsEnum.other.value(), String.join(",",names));
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 E", Locale.CHINA);
        dataMap.put(ShiftsEnum.operating_time.value(), dateFormat.format(DateUtil.parse(scheduleTime, "yyyy-MM-dd")));

        Integer targetWidth = 555;
        Integer targetHeight = 276;
        Double scale = 0.64D;
        Integer embedSheetIndex = 4;
        Integer embedImageIndex = 5;
        List<String> propertyKeys = Arrays.stream(ShiftsEnum.values()).map(shiftsEnum -> shiftsEnum.value()).collect(Collectors.toList());

        Map<String, ExcelToImageUtil.DrawingCellInfo> cellInfoMap = new HashMap<>();
        ExcelToImageUtil.DrawingCellInfo titleCellInfo = new ExcelToImageUtil.DrawingCellInfo();
        String titleCellKey = "00";
        cellInfoMap.put(titleCellKey,ExcelToImageUtil.createDrawingCellInfo(titleCellKey,ExcelToImageUtil.DrawingCellInfo.ALIGN_LEFT,new java.awt.Font("宋体", java.awt.Font.PLAIN, 44)));

        String prepareCellKey = "11";
        cellInfoMap.put(prepareCellKey,ExcelToImageUtil.createDrawingCellInfo(prepareCellKey,ExcelToImageUtil.DrawingCellInfo.ALIGN_LEFT,null));

        String otherCellKey = "12";
        cellInfoMap.put(otherCellKey,ExcelToImageUtil.createDrawingCellInfo(otherCellKey,ExcelToImageUtil.DrawingCellInfo.ALIGN_LEFT,null));

        String scheduleTimeCellKey = "13";
        cellInfoMap.put(scheduleTimeCellKey,ExcelToImageUtil.createDrawingCellInfo(scheduleTimeCellKey,ExcelToImageUtil.DrawingCellInfo.ALIGN_LEFT,null));

        //刷新关联对象内容
        ExcelToImageUtil.refreshEmbedObj(writer,dataMap,embedSheetIndex,embedImageIndex,targetWidth,targetHeight,scale,propertyKeys,false,cellInfoMap);
    }

    /**
     * 返回区域排班信息时 将手术台数返回
     * @param time
     * @param nurseName
     * @param regionId
     * @return
     */
    public RegionSurgicalVo getRegionSurgical(String time, String nurseName, String regionId) {
        RegionSurgicalVo res = new RegionSurgicalVo();
        List<SurgicalVo> surgicalVos = this.listScheduledSurgical(time, nurseName, Arrays.asList(regionId), null);
        res.setSurgicalList(surgicalVos);
        res.setNum(surgicalVos.size());
        return res;
    }

    @Transactional
    public void batchSchedulingSurgical(List<SurgicalRoomAndAssistantDTO> roomAndAssistants) {
        if (!ObjectUtils.isEmpty(roomAndAssistants)){
            //检查区域权限
            checkRegion(roomAndAssistants.get(0).getRegionId());
            for (SurgicalRoomAndAssistantDTO roomAndAssistant : roomAndAssistants) {
                roomAndAssistant.setStatus(SCHEDULED_STATUS);
                this.schedulingSurgical(roomAndAssistant,false);
            }
        }
    }

    /**
     * 获取排班数据
     * @param scheduleTime 排班时间
     * @return
     */
    private Map<String, String> getDataMap(String scheduleTime){
        ShiftsSimpleVo shifts = shiftsService.getShifts(scheduleTime);
        //右上表
        Map<String, String> dataMap = new HashMap<>();
        if (!ObjectUtils.isEmpty(shifts) && !ObjectUtils.isEmpty(shifts.getItems())){
            dataMap = shifts.getItems().stream().collect(Collectors.toMap(
                    ShiftsItemVo::getScheduleId,
                    shiftsItemVo -> {
                        List<String> nameList = new ArrayList<>();
                        if (!ObjectUtils.isEmpty(shiftsItemVo.getNurseList())){
                            nameList = shiftsItemVo.getNurseList().stream().map(
                                    nurse -> nurse.getName()
                            ).collect(Collectors.toList());
                        }
                        return String.join(",",nameList);
                    }
            ));
        }
        return dataMap;
    }

    /**
     * 修改排班状态
     * @param surgicalId
     * @param status
     */
    private void switchSchedulingStatus(String surgicalId,Integer status){
        SurgicalEntity surgicalEntity = new SurgicalEntity();
        surgicalEntity.setId(surgicalId);
        surgicalEntity.setSchedulingStatus(status);
        baseMapper.updateById(surgicalEntity);
    }

    @Transactional
    public IPage<SurgicalVo> pageSurgical(Page<SurgicalVo> page, String time, String masterDoctorName, Integer schedulingStatus, String regionId) {
        List<String> surgicalIds = baseMapper.pageSurgicalId(page,time, masterDoctorName, schedulingStatus, regionId);
        List<SurgicalVo> surgicalVos = baseMapper.listAllSurgical(time, masterDoctorName, null, schedulingStatus, regionId, surgicalIds);
        page.setRecords(surgicalVos);
        return page;
    }

    public void checkRegion(String regionId){
        LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        List<UserRegionVo> regionVos = userRegionService.getRegionByUserId(loginUser.getUser().getId());
        if (!ObjectUtils.isEmpty(regionVos)){
            for (UserRegionVo regionVo : regionVos) {
                if (Objects.equals(regionId,regionVo.getRegionId())){
                    return;
                }
            }
        }
        throw new RuntimeException("没有该区域的排班权限");
    }

    public List<RoomSchedulingVO> listScheduling(SchedulingQuery query) {
        return baseMapper.listScheduling(query);
    }

    public IPage<WnReadHandNumbness> pageThirdSurgical(SurgicalQuery query) {
        IPage<WnReadHandNumbness> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<WnReadHandNumbness> list = baseMapper.pageThirdSurgical(query, query.getDisAblePage() ? null : page);
        page.setRecords(list);
        return page;
    }

    public List<RoomSurgicalAndEnvVO> listRoomSurgicalAndEnv(SurgicalAndEnvQuery query) {
        //查询手术间排班信息
        List<RoomSurgicalAndEnvVO> list = baseMapper.listRoomSurgicalAndEnv(query);

        //查询房间环境信息
        RoomEnvQuery roomEnvQuery = new RoomEnvQuery();
        if (!ObjectUtils.isEmpty(query.getTargetDate())){
            roomEnvQuery.setTargetDate(query.getTargetDate());
        }else{
            roomEnvQuery.setTargetDate(DateUtil.formatDate(new Date()));
        }
        List<RoomEnvVO> envList = baseMapper.listRoomEnv(roomEnvQuery);
        Map<String,RoomEnvVO> envMap = new HashMap<>();
        if (!ObjectUtils.isEmpty(envList)){
            envMap = envList.stream().collect(Collectors.toMap(RoomEnvVO::getOrName, Function.identity()));
        }

        if (!ObjectUtils.isEmpty(list)){
            for (RoomSurgicalAndEnvVO roomSurgicalAndEnvVO : list) {
                RoomEnvVO roomEnvVO = envMap.get(roomSurgicalAndEnvVO.getAliasName());
                if (!ObjectUtils.isEmpty(roomEnvVO)){
                    roomSurgicalAndEnvVO.setCurTemp(roomEnvVO.getCurTemp());
                    roomSurgicalAndEnvVO.setCurHumd(roomEnvVO.getCurHumd());
                    roomSurgicalAndEnvVO.setCurPressDiff(roomEnvVO.getCurPressDiff());
                    roomSurgicalAndEnvVO.setRecordTime(roomEnvVO.getRecordTime());
                }
            }
        }

        return list;
    }
}
